import { defineStore } from "pinia";
import { ref } from "vue";
import type Typings from "@/typings";

const useMenuStore = defineStore(
  "menuStore",
  () => {
    // 设置默认值才能被 $reset 重置
    const menuList = ref<Typings.XtPublic.Menu.item[]>([]);

    const setMenuList = () => {
      const fixedMenu: Typings.XtPublic.Menu.item[] = [
        {
          title: "首页",
          path: "/dashboard",
          icon: "icon-shouye1-copy",
        },

        {
          title: "权限管理",
          path: "/permission",
          icon: "icon-xitongquanxian",
          children: [
            {
              title: "用户",
              path: "/user",
            },
          ],
        },
      ];

      menuList.value = fixedMenu;
    };

    return {
      menuList,
      setMenuList,
    };
  },
  {
    persist: {
      enabled: true,

      strategies: [
        {
          storage: sessionStorage,
          paths: ["menuList"],
        },
      ],
    },
  } as any
);

export default useMenuStore;
